var handlerObject=new Object();
function handler(request,response){
    var handler=request.getParameter("h");
    if(request.getSession().getAttribute("adminid")==null&&handler!="login"){
        response.sendRedirect("/");
    }else{
        var reg = /^[0-9a-zA-Z]+$/; 
        if(reg.test(handler)){
            handlerObject[handler](request,response);
        }else{
            httpSession.removeAttribute("adminid");
        }
    }
}
/**用户登录**/
handlerObject.login=function(request,response){
    var obj={};
    var config=Packages.js.web.center.core.config.JsWebConfig;
    if(request.getParameter("name")==config.adminName&&request.getParameter("pass")==config.adminPwd){
        var httpSession=request.getSession();
        httpSession.setAttribute("adminid","1");
        obj.result=1;
        obj.msg="登录成功";        
    }else{
        obj.result=0;
        obj.msg="用户名密码错误！";
    }
    self.send(response,JSON.stringify(obj));
}
/**退出系统**/
handlerObject.exit=function(request,response){
    var httpSession=request.getSession();
    httpSession.removeAttribute("adminid");
}
/**关闭整个系统**/
handlerObject.close=function(request,response){
    sys.exit(1);
}
/**请空所有共享对象**/
handlerObject.cleanShareObject=function(request,response){
    Packages.js.web.center.utils.JsWebDatabaseMapUtils.clean();
}
/**停止websocket服务**/
handlerObject.stopWebSocket=function(request,response){

}